(function($){
    //实现效果
    function Lunboaaa(ele,opt){
        var d = {
            dDisplay:0,
            autoPlay:false,
            interval:2000
        };
        this.opt =$.extend({},d,opt);
        this.wrap=ele;
        this.dDisplay=this.opt.dDisplay;
        this.$img=this.wrap.find('img');
        this.imglen=this.$img.length;
        this.nowIndex=0;
        this.autoPlay=this.opt.autoPlay;
        this.timer=null;
        this.interval=this.opt.interval;
        this.init();
    }
    Lunboaaa.prototype.init=function(){
        this.initMove();
        this.btn();
    }
    Lunboaaa.prototype.initMove=function(){
        var self=this;
        var slength=Math.floor(self.imglen/2);
        var lNum,
            rNum;
        for(var i=0;i<slength;i++){
            lNum=self.dDisplay-i-1;
            self.$img.eq(lNum).css({
                transform:'translateX('+(-150*(i+1))+'px) translateZ('+(200-i*100)+'px) rotateY(30deg)'
            })
            rNum=self.dDisplay+i+1;
            self.$img.eq(rNum).css({
                transform:'translateX('+(150*(i+1))+'px) translateZ('+(200-i*100)+'px) rotateY(-30deg)'
            })
        }
        self.$img.eq(self.dDisplay).css({
            transform:'translateZ(300px)'
        })
    }

    Lunboaaa.prototype.btn=function(){
        var self=this;
        self.$img.on('click',function(){
            self.nowIndex=$(this).index();
            self.moving(self.nowIndex)
        }).hover(function(){
            clearInterval(self.timer)
        },function(){
            self.timer=setInterval(function(){
                self.play();
            },self.interval)
        })
        this.timer=setInterval(function(){
            self.play();
        },this.interval)


    }
    Lunboaaa.prototype.moving=function(index){
        this.dDisplay=index;
        this.initMove();
    }
    Lunboaaa.prototype.play=function (){
        if(this.autoPlay){
            if(this.nowIndex==this.imglen-1){
                    this.nowIndex=0;

            }else{
                this.nowIndex++;
            }
            this.moving(this.nowIndex);
        }
    }
    //实现插件
    $.fn.extend({
        lunboaaa:function (opt){
            new Lunboaaa(this,opt)
        }
    })

})(jQuery)